package org.gpp.proj1.robot.action.step;

import java.security.InvalidParameterException;
import java.util.List;

import org.gpp.proj1.robot.Robot;
import org.gpp.proj1.robot.part.EquippedPart;

/**
 * Action that changes a robot's animation
 *  
 * @author Paolo Victor, paolovictor@gmail.com
 */
public class ChangeTargetAnimationActionStep implements ActionStep {
	
	/**
	 * The animation that will be changed to
	 */
	private String animation;

	/**
	 * Default constructor
	 * @param target
	 * @param animation
	 */
	public ChangeTargetAnimationActionStep( String animation ) {
		assert animation != null : "Cannot create an action with a null animation";
		
		this.animation = animation;
	}
	
	/**
	 * Executes the action
	 */
	public void execute( EquippedPart parent, List<Robot> targets ) {
		assert targets != null : "This actions requires a non-null target list";
		
		for( Robot target : targets ) {
			target.setAnimation( animation );
		}
	}
	
	/**
	 * @return
	 */
	public String getAnimation() {
		return animation;
	}

	/* (non-Javadoc)
	 * @see org.gpp.proj1.robot.action.step.ActionStep#execute(org.gpp.proj1.robot.part.EquippedPart)
	 */
	public void execute(EquippedPart parent) {
		throw new InvalidParameterException( "This action requires a target list" );
	}
}